package com.ruoyi.material.service.impl;

import java.util.List;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.material.mapper.MaterialTypesMapper;
import com.ruoyi.material.domain.MaterialTypes;
import com.ruoyi.material.service.IMaterialTypesService;

/**
 * 物料类型Service业务层处理
 *
 * @author 山海
 * @date 2024-09-12
 */
@Service
public class MaterialTypesServiceImpl implements IMaterialTypesService {
    @Autowired
    private MaterialTypesMapper materialTypesMapper;

    /**
     * 查询物料类型
     *
     * @param id 物料类型主键
     * @return 物料类型
     */
    @Override
    public MaterialTypes selectMaterialTypesById(Long id) {
        return materialTypesMapper.selectMaterialTypesById(id);
    }

    /**
     * 查询物料类型列表
     *
     * @param materialTypes 物料类型
     * @return 物料类型
     */
    @Override
    public List<MaterialTypes> selectMaterialTypesList(MaterialTypes materialTypes) {
        return materialTypesMapper.selectMaterialTypesList(materialTypes);
    }

    /**
     * 新增物料类型
     *
     * @param materialTypes 物料类型
     * @return 结果
     */
    @Override
    public int insertMaterialTypes(MaterialTypes materialTypes) {
        materialTypes.setCreateTime(DateUtils.getNowDate());
        // 山海添加  设置 创建人
        materialTypes.setCreateBy(SecurityUtils.getUsername());
        return materialTypesMapper.insertMaterialTypes(materialTypes);
    }

    /**
     * 修改物料类型
     *
     * @param materialTypes 物料类型
     * @return 结果
     */
    @Override
    public int updateMaterialTypes(MaterialTypes materialTypes) {
        materialTypes.setUpdateTime(DateUtils.getNowDate());
        // 山海添加  设置 修改人
        materialTypes.setUpdateBy(SecurityUtils.getUsername());
        return materialTypesMapper.updateMaterialTypes(materialTypes);
    }

    /**
     * 批量删除物料类型
     *
     * @param ids 需要删除的物料类型主键
     * @return 结果
     */
    @Override
    public int deleteMaterialTypesByIds(Long[] ids) {
        return materialTypesMapper.deleteMaterialTypesByIds(ids);
    }

    /**
     * 删除物料类型信息
     *
     * @param id 物料类型主键
     * @return 结果
     */
    @Override
    public int deleteMaterialTypesById(Long id) {
        return materialTypesMapper.deleteMaterialTypesById(id);
    }
}
